package com.aopcinemas.common.model;

import jade.core.Agent;
import jade.core.behaviours.Behaviour;

public abstract class AbstractRegistrationBehavior extends Behaviour {

    private static final long serialVersionUID = 1L;

    public static final int REGISTER = 1;
    public static final int UNREGISTER = 2;

    private int action = REGISTER;

    private boolean done = false;

    public AbstractRegistrationBehavior(Agent agent) {
        super(agent);
    }

    public AbstractRegistrationBehavior(Agent agent, int action) {
        this(agent);
        this.action = action;
    }

    @Override
    public void action() {
        switch (action) {
            case REGISTER: {
                doRegister();
                break;
            }
            case UNREGISTER: {
                doUnregister();
                break;
            }
        }
        done = true;
    }

    protected abstract void doUnregister();

    protected abstract void doRegister();

    @Override
    public boolean done() {
        return done;
    }

}
